<template>
  <d2-container class="page">
    <header>您好, {{info?info.name:''}}！欢迎登入 综合能源智慧计量管控平台
    </header>
    <el-row :gutter="20" style="margin-bottom: 20px;">
      <el-col :span="12">
        <div class="panel">
          <div class="title">区域用量</div>
          <div class="chart">
            <ve-pie :data="chartData" :settings="chartSetting" height="100%" :log="true"
                    :legend="{orient: 'vertical',right: 10,top:'middle'}"
            />
          </div>
        </div>
      </el-col>
      <el-col :span="12">
        <div class="panel">
          <div class="title">区域设备</div>
          <div class="chart">
            <ve-bmap
              height="100%"
              :settings="mapChartSetting"
              :series="mapChartData"
              :tooltip="{show:true}">
            </ve-bmap>
          </div>
        </div>
      </el-col>
    </el-row>
    <el-row>
      <el-col>
        <div class="panel">
          <div class="title">今年同比用量</div>
          <div class="chart">
            <ve-line :data="tongbiChartData" :settings="tongbiChartSetting" height="100%" :grid="{top:40,bottom: 20}"  :legend="{top: 10}"></ve-line>
          </div>
        </div>
      </el-col>
    </el-row>
  </d2-container>
</template>

<script>
import { mapState } from 'vuex'
import VePie from 'v-charts/lib/pie'
import VeBmap from 'v-charts/lib/bmap'
import VeLine from 'v-charts/lib/line'

export default {
  components: {
    VePie,VeBmap,VeLine
  },
  computed: {
    ...mapState('d2admin/user', [
      'info'
    ])
  },
  data() {
    return {
      chartSetting: {
        offsetY: '50%'
      },
      chartData: {
        columns: ['area', 'cost', 'profit'],
        rows: [
          { 'area': '江苏', 'cost': 123, 'profit': 3 },
          { 'area': '上海', 'cost': 1223, 'profit': 6 },
          { 'area': '北京', 'cost': 2123, 'profit': 90 },
          { 'area': '浙江', 'cost': 4123, 'profit': 12 },
        ]
      },
      mapChartSetting: {
        key: 'waOmHmK1P6Dqc6IGDeVFGWCIk9fQGQXZ',
        bmap: {
          center: [120, 30],
          zoom: 14,
          roam: true,
          mapStyle: {}
        }
      },
      mapChartData: [
        {
          type: 'scatter',
          coordinateSystem: 'bmap',
          data: [
            [120, 30, 1] // 经度，维度，value，...
          ]
        }
      ],
      tongbiChartSetting: {
        labelMap: {
          datetime: '时间',
          value: '用量'
        },
      },
      tongbiChartData:{
        columns: ['datetime','value'],
        rows:[
          {datetime: '2018', value: 0},
          {datetime: '2019', value: 0},
          {datetime: '2020', value: 1000},
        ]
      }
    }
  }
}
</script>

<style lang="scss" scoped>
.page {
  color: $color-text-normal;
  header{
    padding: 10px 0 20px;
  }
  .panel {
    border: 1px solid #ddd;
    border-radius: 5px;
    .title {
      font-size: 16px;
      line-height: 40px;
      border-bottom: 1px solid #ddd;
      padding-left: 10px;
      background: #f5f5f5;
    }
    .chart {
      width: 100%;
      height: 300px;
    }
  }
}
</style>
